package hotel.modal;

import hotel.dao.RoomChangeDao;
import javafx.beans.property.*;

public class RoomChange {
	private SimpleIntegerProperty changeId;		// 换房编号
	private SimpleStringProperty preOrderId;	// 开房单号
	private SimpleStringProperty preRoomNo;		// 换前房间号
	private SimpleStringProperty nowRoomNo;		// 换后房间号
	private SimpleStringProperty changeTime;	// 换房时间
	private SimpleStringProperty comment;		// 备注信息
	protected SimpleBooleanProperty modified;
	
	private void init(RoomChangeDao rcd) {
		if(rcd != null) {
			this.changeId = new SimpleIntegerProperty(rcd.getChangeId());
			this.preOrderId = new SimpleStringProperty(rcd.getPreOrderId());
			this.preRoomNo = new SimpleStringProperty(rcd.getPreRoomNo());
			this.nowRoomNo = new SimpleStringProperty(rcd.getNowRoomNo());
			this.changeTime = new SimpleStringProperty(rcd.getChangeTime());
			this.comment = new SimpleStringProperty(rcd.getComment());
		}else {
			this.changeId = new SimpleIntegerProperty(0);
			this.preOrderId = new SimpleStringProperty("");
			this.preRoomNo = new SimpleStringProperty("");
			this.nowRoomNo = new SimpleStringProperty("");
			this.changeTime = new SimpleStringProperty("");
			this.comment = new SimpleStringProperty("");
		}
		this.modified = new SimpleBooleanProperty(false);
	}
	
	public RoomChange(RoomChangeDao rcd){
		init(rcd);
	}
	
	public RoomChange() {
		init(null);
	}
	
	public Object getDao() {
		RoomChangeDao rcd = new RoomChangeDao();
		rcd.setChangeId(changeId.get());
		rcd.setPreOrderId(preOrderId.get());
		rcd.setPreRoomNo(preRoomNo.get());
		rcd.setNowRoomNo(nowRoomNo.get());
		rcd.setChangeTime(changeTime.get());
		rcd.setComment(comment.get());
		return rcd;
	}
	
	public RoomChange(RoomChange roomChange) {
		this.changeId = new SimpleIntegerProperty(roomChange.getChangeId());
		this.preOrderId = new SimpleStringProperty(roomChange.getPreOrderId());
		this.preRoomNo = new SimpleStringProperty(roomChange.getPreRoomNo());
		this.nowRoomNo = new SimpleStringProperty(roomChange.getNowRoomNo());
		this.changeTime = new SimpleStringProperty(roomChange.getChangeTime());
		this.comment = new SimpleStringProperty(roomChange.getComment());
		this.modified = new SimpleBooleanProperty(false);
	}
	
	public RoomChange(int changeId, String preOrderId, String preRoomNo, String nowRoomNo, String changeTime, String comment) {
		this.changeId = new SimpleIntegerProperty(changeId);
		this.preOrderId = new SimpleStringProperty(preOrderId);
		this.preRoomNo = new SimpleStringProperty(preRoomNo);
		this.nowRoomNo = new SimpleStringProperty(nowRoomNo);
		this.changeTime = new SimpleStringProperty(changeTime);
		this.comment = new SimpleStringProperty(comment);
		this.modified = new SimpleBooleanProperty(false);
	}
	
	@Override
	public String toString() {
		String str = String.format("ChangeId:%d PreOrderId:%s PreRoomNo:%s NowRoomNo:%s ChangeTime:%s Comment:%s",
				changeId.get(), preOrderId.get(), preRoomNo.get(), nowRoomNo.get(), changeTime.get(), comment.get());
		return str;
	}
	
	public final SimpleIntegerProperty changeIdProperty() {
		return this.changeId;
	}
	public final int getChangeId() {
		return this.changeIdProperty().get();
	}
	public final void setChangeId(final int changeId) {
		this.changeIdProperty().set(changeId);
	}
	public final SimpleStringProperty preOrderIdProperty() {
		return this.preOrderId;
	}
	public final String getPreOrderId() {
		return this.preOrderIdProperty().get();
	}
	public final void setPreOrderId(final String preOrderId) {
		this.preOrderIdProperty().set(preOrderId);
	}
	public final SimpleStringProperty preRoomNoProperty() {
		return this.preRoomNo;
	}
	public final String getPreRoomNo() {
		return this.preRoomNoProperty().get();
	}
	public final void setPreRoomNo(final String preRoomNo) {
		this.preRoomNoProperty().set(preRoomNo);
	}
	public final SimpleStringProperty nowRoomNoProperty() {
		return this.nowRoomNo;
	}
	public final String getNowRoomNo() {
		return this.nowRoomNoProperty().get();
	}
	public final void setNowRoomNo(final String nowRoomNo) {
		this.nowRoomNoProperty().set(nowRoomNo);
	}
	public final SimpleStringProperty changeTimeProperty() {
		return this.changeTime;
	}	
	public final String getChangeTime() {
		return this.changeTimeProperty().get();
	}
	public final void setChangeTime(final String changeTime) {
		this.changeTimeProperty().set(changeTime);
	}
	public final SimpleStringProperty commentProperty() {
		return this.comment;
	}
	public final String getComment() {
		return this.commentProperty().get();
	}
	public final void setComment(final String comment) {
		this.commentProperty().set(comment);
	}
	public final SimpleBooleanProperty modifiedProperty() {
		return this.modified;
	}
	public final boolean isModified() {
		return this.modifiedProperty().get();
	}
	public final void setModified(final boolean modified) {
		this.modifiedProperty().set(modified);
	}
}
